<?php
   header("content-type:text/html;charset=utf8");
   $dsn = "mysql:host=localhost;dbname=demo;charset=utf8";
   $pdo = new PDO($dsn,'root','root');
   $sql = "SELECT * FROM book";
   $res = $pdo->query($sql);
   $data = $res->fetchAll(PDO::FETCH_ASSOC);

?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
	<title></title>
</head>
<body>
 <table border="1">
 	<tr>
 		<td>编号</td>
 		<td>图书名称</td>
 		<td>图书价格</td>
 		<td>图书介绍</td>
 		<td>操作</td>
 	</tr>
 	<?php foreach ($data as $key => $value){?>
 	<tr>
 		<td><?= $value['id']?></td>
 		<td><?= $value['name']?></td>
 		<td><?= $value['price']?></td>
 		<td><?= $value['descs']?></td>
 		<td>
 		    <a href="">编辑</a>
 			<a href="del.php?id=<?= $value['id']?>">删除</a>
 		</td>
 	</tr>
 	<?php } ?>
 	
 </table>
</body>
</html>
